package com.web.dao;

import com.web.entity.InstantLifeComment;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface InstantLifeCommentMapper {
    @Delete({
        "delete from APP_INSTANT_LIFE_COMMENT",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_INSTANT_LIFE_COMMENT (topic_id, topic_type, ",
        "content, from_uid, ",
        "create_time, modify_time)",
        "values (#{topicId,jdbcType=INTEGER}, #{topicType,jdbcType=INTEGER}, ",
        "#{content,jdbcType=VARCHAR}, #{fromUid,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(InstantLifeComment record);

    int insertSelective(InstantLifeComment record);

    @Select({
        "select",
        "id, topic_id, topic_type, content, from_uid, create_time, modify_time",
        "from APP_INSTANT_LIFE_COMMENT",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    InstantLifeComment selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(InstantLifeComment record);

    @Update({
        "update APP_INSTANT_LIFE_COMMENT",
        "set topic_id = #{topicId,jdbcType=INTEGER},",
          "topic_type = #{topicType,jdbcType=INTEGER},",
          "content = #{content,jdbcType=VARCHAR},",
          "from_uid = #{fromUid,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(InstantLifeComment record);

    List<InstantLifeComment> getCommentList(@Param("topicType") String topicType,@Param("topicId") String topicId);
}